**************************
*Dynamic Legitimacy in Territorial Conflicts
*
*Lesley-Ann Daniels and Marc Sanjaume-Calvet

*Published: Territory, Politics, Governance, 2024



*DESCRIPTIVES
sum i.female i.age i.educ4c i.house i.ethnicity_binary

*balance checks
*primelegit_A - ethnic and human rights
*primelegit_B - ethnic and control
*primelegit_C - human rights and control

ttest female, by(primelegit_A)
ttest age, by(primelegit_A)
ttest educ4c, by(primelegit_A)
ttest house, by(primelegit_A)
ttest identity, by(primelegit_A)
ttest victim, by(primelegit_A)


*ANALYSIS

**SURVEY SET
svyset _n [pweight = weightAGK]


***OLS results
*Table A2 Appendix
eststo, title("Model 1"): quietly svy: reg ruletoday b3.primelegit 
eststo, title("Model 2"): quietly svy: reg ruletoday b3.primelegit i.female i.age i.educ4c i.house i.ethnicity_binary
eststo, title("Model 3"): quietly svy: reg ruletoday b3.primelegit##i.ethnicity_binary 
eststo, title("Model 4"): quietly svy: reg ruletoday b3.primelegit##i.ethnicity_binary i.female i.age i.educ4c i.house 
estout, cells(b(star  fmt(%9.3f)) se(par fmt(2))) label varlabels(_cons Constant) title(GAM rule) stats(N r2, label(Observations RSquared)) starlevels(* 0.05 ** 0.01 *** 0.001)
eststo clear


* margins plots
*Figure 2 main article
gen gamtoday = ruletoday*20
quietly svy: reg gamtoday b3.primelegit i.female i.age i.educ4c i.house i.ethnicity_binary
margins primelegit, plot(recast(scatter) ytitle(Rule today) xtitle() title ("")  graphregion(fcolor(white)))

*Figure 3 main article
quietly svy: reg gamtoday b3.primelegit##i.ethnicity_binary i.female i.age i.educ4c i.house
margins primelegit#i.ethnicity_binary, plot(recast(scatter) ytitle(Rule today) xtitle() title ("") graphregion(fcolor(white)))



